home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / c01oop.zip / CPPWKBK / CPPV1-3.CPP < prev    next >
C/C++ Source or Header  |  1992-08-25  |  529b  |  39 lines

  1. #define HEADER "C++ Problem 1.3 by Rick Conn using Borland C++"
  2.  
  3. #include <stdio.h>
  4.  
  5. struct P {
  6.   int value;
  7. public:
  8.   void set (int);
  9.   void print (void);
  10.   friend void printit(P);
  11. };
  12.  
  13. void P::set (int new_value)
  14. {
  15.   value = new_value;
  16. }
  17.  
  18. void P::print (void)
  19. {
  20.   printf("%10d\n", value);
  21. }
  22.  
  23. void printit (P inP)
  24. {
  25.   printf("%10d\n", inP.value);
  26. }
  27.  
  28. void main(void)
  29. {
  30.   printf("%s\n", HEADER);
  31.  
  32.   P pobject;
  33.   pobject.set (12);
  34.   pobject.print();
  35.   pobject.set (14);
  36.   printit (pobject);
  37. }
  38.  
  39.